<script>
  function lazyloadFn() {
    let totalShowHeight = (window.innerHeight || document.documentElement.clientHeight) +
      (document.body.scrollTop || document.documentElement.scrollTop)
    let imgsObj = document.querySelectorAll('img')
    imgsObj.forEach(item => {
      let currentImgHeight = item.offsetTop
      if (totalShowHeight > currentImgHeight) {
        item.src = item.getAttribute('data-original')
      }
    })
  }


  window.onscroll = lazyloadFn

  lazyloadFn()
</script>